package com.grouplay.dao;

import com.grouplay.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository("userDao")
public interface IUserDao {

    @Insert("insert into user (email, name, password, password_salt, balance) values (#{email}, #{name}, #{password}, #{password_salt}, #{balance})")
    void insert(User user);

    @Select("select * from user where email = #{email}")
    User findUserByEmail(String email);

    @Select("select * from user where name = #{name}")
    User findUserByName(String name);

    @Update("update user set name = #{name}, password = #{password} where id = #{id} and email = #{email}")
    void updateUser(User user);

    @Select("select balance from user where id = #{id}")
    Double findBalanceById(Integer id);

    @Update("update user set balance = #{balance} where id = #{id}")
    void updateUserBalance(User user);
}
